package com.hfy.music.controller;

import com.hfy.music.service.MusicService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import result.Result;

/**
 * @ author 韩
 * time: 2024/5/21 2:37
 */
@RestController
@RequestMapping("/query")
@Tag(name = "发现音乐控制器",description = "就是查询音乐信息并展示")
public class MusicController {

    @Autowired
    private MusicService findMusicService;

    @Operation(summary = "在首页进行分页查询，获取列表数据")
    @Parameters(@Parameter(name = "pageNum",description = "分页数"))
    @GetMapping("/page/{pageNum}")
    public Result queryByPage(@PathVariable("pageNum") int pageNum) {
        return findMusicService.queryByPage(pageNum);
    }

    @Operation(summary = "根据音乐关键词进行分词搜索，获取音乐列表数据，做分页查询")
    @Parameters({@Parameter(name = "key",description = "关键字"),
                @Parameter(name = "pageNum",description = "分页数")})
    @GetMapping("/music/key")
    public Result queryByMusicKey(@RequestParam("key") String key, @RequestParam("pageNum") Integer pageNum) {
        return findMusicService.queryByMusicKey(key,pageNum);
    }

    @Operation(summary = "根据专辑关键词进行分词搜索，获取音乐列表数据")
    @Parameters({@Parameter(name = "key",description = "关键字"),
            @Parameter(name = "pageNum",description = "分页数")})
    @GetMapping("/album/key")
    public Result queryByAlbumKey(@RequestParam("key") String key, @RequestParam("pageNum") Integer pageNum) {
        return findMusicService.queryByAlbumKey(key,pageNum);
    }





}

